// pages/withdrawal/withdrawal.js
import { query, oxt, rmb} from '../../utils/util.js'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    withDrawlType: 0,
    type: 0,
    amount: 0,
    mobile: '',
    typeList: {
      '1': [
        {
          label: '提现方式',
          placeholder: '默认银行卡',
          change: true
        },
        {
          label: '金额',
          placeholder: '请输入您要提现的金额',
          mode: 'number'
        }
      ],
      '2': [
        {
          label: 'ID号',
          placeholder: '请输入您的ID号',
          mode: 'number'
        },
        {
          label: '姓名',
          placeholder: '请输入您的姓名'
        },
        {
          label: '金额',
          placeholder: '请输入您要提现的金额',
          mode: 'number'
        }
      ]
    }
  },

  onShow: function() {
    console.log(this.data.type, '998877')
  },

  onLoad: function(options) {
    let {amount} = this.data
    const { type, rmb, oxt } = options
    amount = type === 1 ? rmb : oxt
    console.log(amount, 'show sum')
    this.setData({
      withDrawlType: type,
      amount
    })
  },

  handleWithDrawl: function() {
    const {type, amount, mobile} = this.data
    if (withDrawlType === '1') {
      oxt({type, amount, mobile})
      .then(res => {

      })
      .catch(e => {
        console.log(e, 'OTC提现')
      })
    }else {
      rem({type, amount})
      .then(res => {

      })
      .catch(e => {
        console.log(e, '人民币提现')
      })
    }
  },

  navigate: function() {
    wx.navigateTo({
      url: '/pages/payMethod/payMethod',
    })
  }
})